//
//  checkOutViewController.m
//  HondaPro_2
//
//  Created by glendale on 13-6-17.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "checkOutViewController.h"
#import "PhotoListViewController.h"
#import "PhotoModel.h"
#import "mm_picRecodeDataModel.h"

@interface checkOutViewController ()

@end

@implementation checkOutViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    
    [self.scrollViewDis setContentSize:CGSizeMake(self.scrollViewDis.frame.size.width, 720)];
    
    _vc = [[mm_repairCarCheckViewControllerTmp alloc] initWithFrame:CGRectMake(0, 0, self.scrollViewDis.frame.size.width, 720)];
    _vc.dicRepairCarCheckData = self.dicOutCheckTmp;
    [_vc.viewPictureBtn addTarget:self action:@selector(viewPictureBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollViewDis addSubview:_vc];

}

#pragma mark - outcheckViewDelegate

-(void)viewPictureBtnClicked{
    NSArray *fileList = self.dicOutCheckTmp[@"fileList"];
    if (fileList.count>0) {
        mm_picRecodeDataModel *picDataModel = [mm_picRecodeDataModel sharedModelIns];
        picDataModel.arrForAllCapturePic = nil;//清空
        //加入新图片
        picDataModel.arrForAllCapturePic = [NSMutableArray arrayWithArray:picDataModel.arrForNewImage];
        for (NSDictionary *dic in fileList) {//从数据库获取的图片列表
            if (![self Arr:picDataModel.arrForDeletedImages containsObjec:dic]) {
                PhotoModel *pm = [PhotoModel photoModelWithDic:dic];
                [picDataModel.arrForAllCapturePic addObject:pm];
            }
        }
    }
    PhotoListViewController *vc = [[PhotoListViewController alloc]init];
    vc.editOperation = NO;
    [self.navigationController pushViewController:vc animated:YES];
}

-(BOOL)Arr:(NSArray *)arr containsObjec:(NSDictionary *)dic{
    for (NSDictionary *delectedDic in arr) {
        NSString *itemId = [dic[deletedImageName]stringValue];
        if ([delectedDic[deletedImageName] isEqualToString:itemId]) {
            return true;
        }
    }
    return false;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)backBtn:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidUnload {
    [self setScrollViewDis:nil];
    [super viewDidUnload];
}

@end
